/**
 * Vosao CMS. Simple CMS for Google App Engine.
 * Copyright (C) 2009 Vosao development team
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * email: vosao.dev@gmail.com
 */

package org.vosao.plugins.csdata.entity;


import java.util.Date;
/*import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
*/

import org.vosao.entity.BaseEntityImpl;
//import org.vosao.utils.HashUtil;
import static org.vosao.utils.EntityUtil.*;

import com.google.appengine.api.datastore.Entity;

public class CsdataUserEntity extends BaseEntityImpl {

	//private String name;
	private String email;
	//private String password;
	private Date createdDate;
	//private String sessionKey;
	
	//Xml contentdata ...
	private String data;

	public CsdataUserEntity() {
		createdDate = new Date();
	}
	
	@Override
	public void load(Entity entity) {
		super.load(entity);
		//name = getStringProperty(entity, "name");
		email = getStringProperty(entity, "email");
		//password = getStringProperty(entity, "password");
		createdDate = getDateProperty(entity, "createdDate");
		//sessionKey = getStringProperty(entity, "sessionKey");
		data = getTextProperty(entity, "data");
	}
	
	@Override
	public void save(Entity entity) {
		super.save(entity);
		//setProperty(entity, "name", name, false);
		setProperty(entity, "email", email, true);
		//setProperty(entity, "password", password, false);
		setProperty(entity, "createdDate", createdDate, true);
		//setProperty(entity, "sessionKey", sessionKey, true);
		setTextProperty(entity, "data", data);
	}

	
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public String getCreatedDateString() {
		return createdDate.toString();
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	public String getData() {
		return data;
	}

	public void setData(String data) {
		this.data = data;
	}
	/*public Map<String, String> getValues() {
		Map<String, String> result = new HashMap<String, String>();
		try {
			Document doc = DocumentHelper.parseText(getData());
			for (Element e : (List<Element>)doc.getRootElement().elements()) {
				result.put(e.getName(), e.getText());
			}
		}
		catch (DocumentException e) {
			logger.error(e.getMessage());
		}
		return result;
	}*/
	

	
}
